package com.zysstudy.controller;

import com.zysstudy.domain.User;
import com.zysstudy.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author zhaoyoushui
 * @date 2023/8/22 18:52
 */
@Controller
@RequestMapping(value = "/users",method = RequestMethod.GET)
public class UserController {

    private String prefix = "user";
    @Autowired
    UserService userService;
    /**
     * 用户管理页面
     * @return
     */
    @RequestMapping(method = RequestMethod.GET)
//    @ResponseBody
    public String index(ModelMap map){
//        map.addAttribute("userList", userService.findAll());
        List<User> userList = userService.findAll();
        for (User user : userList) {
            System.out.println(user.toString());
        }
        return this.prefix+"/index";
    }

    @GetMapping("/login")
    public String login(){
        return this.prefix+"/login";
    }

//    @PostMapping("/login")
//    @ResponseBody
//    public String ajaxLogin(String username,String password,boolean rememberMe){
//
//    }
}
